package main

import (
	"fmt"
	"net/http"
	"time"
)

func main() {
	http.HandleFunc("/", getNameHandle)
	err := http.ListenAndServe("127.0.0.1:8080", nil)
	if err != nil {
		fmt.Println("启动失败")
	}
}

func getNameHandle(w http.ResponseWriter, r *http.Request) {
	//fmt.Println("链接地址", r.RemoteAddr)
	//fmt.Println("method", r.Method)
	//fmt.Println("path", r.URL)
	//fmt.Println("head", r.Header)
	//fmt.Println("body", r.Body)
	//w.Header().Add("MyService", "go-http")
	//w.Header().Write()

	time.Sleep(time.Second)
	w.Write([]byte("my name is chang"))
}
